package com.zz.yt.test;

import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;

import com.blankj.utilcode.util.ToastUtils;
import com.whf.android.jar.base.delegate.BaseDelegate;
import com.zz.yt.lib.bluetooth.bt.BtService;
import com.zz.yt.lib.bluetooth.bt.print.AppInfo;
import com.zz.yt.lib.bluetooth.bt.print.PrintUtil;
import com.zz.yt.lib.bluetooth.delegate.print.zk.PrintDelegate;
import com.zz.yt.lib.bluetooth.delegate.print.gp.PrintGprinterDelegate;
import com.zz.yt.lib.bluetooth.delegate.print.mht.PrintMhtDelegate;
import com.zz.yt.lib.bluetooth.delegate.printer.PrinterDelegate;
import com.zz.yt.lib.bluetooth.delegate.temperature.TemperatureAddedDelegate;
import com.zz.yt.lib.bluetooth.delegate.weight.WeightAddedDelegate;
import com.zz.yt.lib.ui.base.BaseMainActivity;
import com.zz.yt.test.click.WeightDelegate;



/**
 * @author qf
 * @version 1.09
 */
public class MainActivity extends BaseMainActivity {

    @Override
    public BaseDelegate setRootDelegate() {
        return WeightDelegate.create();
    }

    @Override
    public boolean isDark() {
        return true;
    }


    public void onClick(View view) {
        getSupportDelegate().start(WeightAddedDelegate.create());
    }

    public void onClick1(View view) {
        getSupportDelegate().start(TemperatureAddedDelegate.create());
    }

    public void onClick2(View view) {
        getSupportDelegate().start(PrintGprinterDelegate.create());
    }

    public void onClick3(View view) {
        getSupportDelegate().start(PrintDelegate.create());
    }

    public void onClick4(View view) {
        getSupportDelegate().start(PrintMhtDelegate.create());
    }

    public void onClick11(View view) {
        //打印图片
        if (TextUtils.isEmpty(AppInfo.btAddress)) {
            ToastUtils.showShort("请连接蓝牙...");
            //startActivity(new Intent(MainActivity.this,SearchBluetoothActivity.class));
        } else {
            ToastUtils.showShort("打印图片...");
            Intent intent2 = new Intent(getApplicationContext(), BtService.class);
            intent2.setAction(PrintUtil.ACTION_PRINT_BITMAP);
            startService(intent2);

        }
    }

    public void onClick12(View view) {
        //打印小票
        if (TextUtils.isEmpty(AppInfo.btAddress)) {
            ToastUtils.showShort("请连接蓝牙...");
            //startActivity(new Intent(MainActivity.this, SearchBluetoothActivity.class));
        } else {
            BluetoothAdapter mAdapter = BluetoothAdapter.getDefaultAdapter();
            if (mAdapter.getState() == BluetoothAdapter.STATE_OFF) {
                //蓝牙被关闭时强制打开
                mAdapter.enable();
                ToastUtils.showShort("蓝牙被关闭请打开...");
            } else {
                ToastUtils.showShort("打印测试...");
                Intent intent = new Intent(getApplicationContext(), BtService.class);
                intent.setAction(PrintUtil.ACTION_PRINT_TEST);
                startService(intent);
            }
        }
    }

    public void onClick13(View view) {
        //打印小票 （多张）
        if (TextUtils.isEmpty(AppInfo.btAddress)) {
            ToastUtils.showShort("请连接蓝牙...");
            //startActivity(new Intent(MainActivity.this,SearchBluetoothActivity.class));
        } else {
            ToastUtils.showShort("打印测试...");
            Intent intent2 = new Intent(getApplicationContext(), BtService.class);
            intent2.setAction(PrintUtil.ACTION_PRINT_TEST_TWO);
            startService(intent2);

        }
    }

    public void onClick14(View view) {
        getSupportDelegate().start(PrinterDelegate.create());
    }

    @Override
    public BaseDelegate outSignIn() {
        return null;
    }

    @Override
    public Class<? extends Activity> outSignInActivity() {
        return null;
    }
}
